﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TelerikAcademyOopProject
{
    public class StockTerminal
    {
        // get command input
        public void ReadComand(StockManager sm,TraderManager tm,Buyer b,Seller s)
        {

            while (true)
            {
                Console.Write("Stock Terminal type command/help: ");
                // get some comand
                string command = Console.ReadLine();

                if (command == "" || command == "exit")
                {
                    Console.WriteLine("See you soon");
                    break;
                }

                // execute this command
                commandList(command,sm,tm,b,s);
            }
        }

        public void commandList(string command, StockManager sm,TraderManager tm,Buyer b,Seller s)
        {
           
            switch (command)
            {
                /* AUTENTICATION COMANDS*/

                case "user-registration":

                    break;

                case "user-login":

                    break;

                /* TRADER COMAND */

                case "buy":
                    
                    Console.WriteLine("Enter Stock Name:");
                    string stockId = Console.ReadLine();
                    tm.buyItem(b, stockId);
                    break;

                case "sell":

                    break;
                   

                /* ITEM COMANDS*/
                case "items":
                        sm.showItems();
                    break;

                case "stocks":
                    sm.showStocks();
                    break;

                case "goods":
                    sm.showGoods();
                    break;

                /* ADMINISTRATION COMMANDS*/

                case "traders-info":
                        //tm.showTraders();
                    break;

                case "add-item":
                        sm.setNewItem();
                    break;

                case "help":
                        help();
                    break;

                default:
                    Console.WriteLine("The comand {0} is not recognised for more info about avalible comands type help", command);
                    break;
            }
        }

        public static void help()
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("----------------------------------------");
            sb.AppendLine("--------------HELP YUNG STOCKERS------- ");
            sb.AppendLine("----------------------------------------");
            sb.AppendLine("Avaliable comands:");
            sb.AppendLine("user-registration : Add new User to the market");
            sb.AppendLine("user-login        : Log in existing user to he market needs User and Password");
            sb.AppendLine("buy               : Buy some product ");
            sb.AppendLine("sell              : Sell some prodcut");
            sb.AppendLine("items/stocks/goods: Show a list of all avalabel Items in general or by type");
            sb.AppendLine("traders-info      : Show information about the avalabel traders");
            sb.AppendLine("add-item          : Add new Item to the networdk, done by Sellers");
            sb.AppendLine("exit              : Exit from the sustems");
            Console.WriteLine(sb.ToString());
        }

        public static void exit(){

            Console.WriteLine("See you soon");
        }
    }
}
